package com.zero.dubbo.data;

import com.zero.dubbo.dao.IUserRpcService;
import com.zero.dubbo.model.User;
import org.apache.dubbo.config.annotation.Reference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class UserRpcServiceTest implements CommandLineRunner {

    private final Logger logger = LoggerFactory.getLogger(getClass());

    @Reference(version = "${dubbo.consumer.IUserRpcService.version}")
    private IUserRpcService userRpcService;

    @Override
    public void run(String... args) throws Exception {

        User user = userRpcService.get(1);
        logger.info("[run][发起一次 Dubbo RPC 请求，获得用户为({})", user);
    }
}
